#include<iostream>
#include<stdio.h>
#include<unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

using namespace std;

int main()
{
    pid_t i=fork();
    if(i==0)//子进程
    {    

        cout<<"before execl,"<<"mypid:"<<getpid()<<endl;
        execl("/usr/bin/ls","ls","-l","-a",NULL);//必须以空 结束
        cout<<"after execl,"<<"mypid:"<<getpid()<<endl;
    }
    else//父进程
    {
        pid_t ret=waitpid(-1,NULL,0);
        if(ret==i)
            cout<<"等待成功,"<<ret<<endl;
    }

    return 0;
}
